package com.cl.unipay4j.ali;

import com.cl.unipay4j.core.pay.INotify;
import com.cl.unipay4j.core.pay.IPayment;
import com.cl.unipay4j.core.pay.IQuery;
import com.cl.unipay4j.core.pay.IRefund;
import com.cl.unipay4j.core.transfer.ITransfer;

/**
 * 支付宝工厂服务类
 *
 * @author  siashan
 * @since v1.0.1
 **/
public class AliPayFactoryProvider {
    private AliPayProperties aliPayProperties;

    private AliPayFactory aliPayFactory;

    public AliPayFactoryProvider(AliPayProperties aliPayProperties, AliPayFactory aliPayFactory) {
        this.aliPayProperties = aliPayProperties;
        this.aliPayFactory = aliPayFactory;
    }

    /**
     * 获取支付对象
     *
     * @param tradeType
     * @return  支付类
     */
    public IPayment getPayment(String tradeType) {
        return aliPayFactory.getPayment(tradeType,aliPayProperties.getConfig());
    }

    /**
     * 获取支付对象
     *
     * @param tradeType   交易类型
     * @param config      支付宝配置
     * @return  支付类
     */
    public IPayment getPayment(String tradeType,AliPayConfig config) {
        return aliPayFactory.getPayment(tradeType,config);
    }


    /**
     * 获取回调对象
     *
     * @return  回调类
     */
    public INotify getNotify() {
        return aliPayFactory.getNotify(aliPayProperties.getConfig());
    }

    /**
     * 获取回调对象
     *
     * @return  回调类
     */
    public INotify getNotify(AliPayConfig config) {
        return aliPayFactory.getNotify(config);
    }

    /**
     * 获取查询对象
     *
     * @return  查询类
     */
    public IQuery getQuery() {
        return aliPayFactory.getQuery(aliPayProperties.getConfig());
    }

    /**
     * 获取查询对象
     *
     * @return  查询类
     */
    public IQuery getQuery(AliPayConfig config) {
        return aliPayFactory.getQuery(config);
    }

    /**
     * 获取转账对象
     *
     * @return  转账类
     */
    public ITransfer getTransfer(){
        return aliPayFactory.getTransfer(aliPayProperties.getConfig());
    }

    /**
     * 获取转账对象
     *
     * @return  转账类
     */
    public ITransfer getTransfer(AliPayConfig config){
        return aliPayFactory.getTransfer(config);
    }

    /**
     * 获取退款对象
     *
     * @return  退款类
     */
    public IRefund getRefund(){
        return aliPayFactory.getRefund(aliPayProperties.getConfig());
    }

    /**
     * 获取退款对象
     *
     * @return  退款类
     */
    public IRefund getRefund(AliPayConfig config){
        return aliPayFactory.getRefund(config);
    }

}
